//
//  SEGPlatformManager.m
//  SEGBasicBussiness
//
//  Created by 刘山 on 2018/3/15.
//  Copyright © 2018年 刘山. All rights reserved.
//

#import "SEGPlatformManager.h"
#import "SEGServerManager.h"

#pragma mark - 不同项目的bundleID

//四格
#define kbundleIdentifierSEGI @"com.segi.uhome"

@implementation SEGPlatformManager
/**
 * 获取app平台号
 * @author Sam
 */
+(NSString*)segAppPlatformCode{
    return kAppPlatformCodeSEGI;
}

+ (NSString *)segCompanyPlatformCode {
    return [self segAppPlatformCode];
}

/**
 * 设置不同平台的Scheme
 * @author Sam
 */
+ (NSString *)segAppScheme {
    return @"opensegiuhome";
}

/// 检测并添加app_platform_code字段
+ (NSString *)getUrlStringWithAppPlatformCode:(NSString *)urlString {
    NSString *app_platform = [NSString stringWithFormat:@"app_platform_code=%@",kAppPlatformCode];
    NSString *company_platform = [NSString stringWithFormat:@"company_platform_code=%@",kAppPlatformCode];
    //app_version_code 修改成接口版本号
    NSString *app_version = [NSString stringWithFormat:@"app_version_code=%@",[SEGServerManager getClientVersionCode]];
    
    if ([urlString rangeOfString:app_platform].location == NSNotFound) {
        //拼app_platform
        if ([urlString rangeOfString:@"?"].location == NSNotFound) {
            //没有任何参数时 用？拼接
            urlString = [NSString stringWithFormat:@"%@?%@", urlString, app_platform];
        }else {
            urlString = [NSString stringWithFormat:@"%@&%@", urlString, app_platform];
        }
    }
    
    if ([urlString rangeOfString:company_platform].location == NSNotFound) {
        //拼app_platform
        if ([urlString rangeOfString:@"?"].location == NSNotFound) {
            //没有任何参数时 用？拼接
            urlString = [NSString stringWithFormat:@"%@?%@", urlString, company_platform];
        }else {
            urlString = [NSString stringWithFormat:@"%@&%@", urlString, company_platform];
        }
    }
    
    if ([urlString rangeOfString:app_version].location == NSNotFound) {
        //拼app_version
        if ([urlString rangeOfString:@"?"].location == NSNotFound) {
            //没有任何参数时 用？拼接
            urlString = [NSString stringWithFormat:@"%@?%@", urlString, app_version];
        }else {
            urlString = [NSString stringWithFormat:@"%@&%@", urlString, app_version];
        }
    }
    
    return urlString;
}

@end
